package com.huangsm.cloud.consumer.client;

import com.google.common.collect.Maps;
import com.huangsm.cloud.consumer.entity.User;
import com.huangsm.cloud.consumer.feign.TestFeignClient;
import com.huangsm.cloud.consumer.feign.UserFeign;
import com.huangsm.cloud.consumer.feign.UserFeign2;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

/**
 * 服务调用接口
 * @author huangsm
 * @version V1.0
 */
@RestController
@Slf4j
public class UserController {

    @Autowired
    private UserFeign userFeign;
    @Value("${server.port}")
    private String port;

    @GetMapping("/findUser/{id}")
    public User findUser(@PathVariable("id") Long id){
        log.info("调用了{}端口服务"+port);
        return userFeign.findUser(id);
    }


    @Autowired
    TestFeignClient testFeignClient;
    @GetMapping("/user/{id}")
    public User findById(@PathVariable Long id) {
        HashMap<String, String> param = Maps.newHashMap();
        param.put("username","zhangsan");
        param.put("password","pwd");
        this.testFeignClient.sumbitForm(param);
        return new User();
    }

}
